package com.liwy3.dynamic;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Copyright © 元气森林（北京）食品科技集团有限公司. All rights reserved.
 *
 * @Description:
 * @author: Crazy4J
 * @date: 2021年11月17日 16:02
 * @version: V1.0
 */
@RestController
public class DynamicController {

    @Resource
    JdbcTemplate jdbcTemplate;

    @GetMapping("/slave")
    @DataSource(DataSourceType.SLAVE)
    public void slave(){
        List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from t_recoup_job where id=73 ");
        System.out.println(maps);
    }
    @GetMapping("/master")
    @DataSource(DataSourceType.MASTER)
    public void master(){
        List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from t_recoup_job where id=73 ");
        System.out.println(maps);
    }
}
